<!--反馈详情-->
<?php

use yii\widgets\ActiveForm ;
use backend\service\AdminUserService ;
use yii\helpers\ArrayHelper ;
use common\service\ConstatService ;
use yii\helpers\Url ;
use common\service\UtilService ;

$pageName = "反馈详情";

$controller = Yii::$app->controller->id;
$action = Yii::$app->controller->action->id;
$this->title = $pageName . "-" . Yii::$app->params['webname'];
$this->params['breadcrumbs'][] = $pageName;
$this->params['display_name'] = $pageName;

$typeId = Yii::$app->admin->identity->type_id ;

$typeArr = [ConstatService::ADMIN_USER_TYPE_ID_MANAGER,ConstatService::ADMIN_USER_TYPE_ID_GENERAL] ;
$users = AdminUserService::getUser($typeArr) ;
$arr = ArrayHelper::map($users,"user_id","username") ;
$usersArr =[] ;
$usersArr["0"]="请选择" ;
foreach($arr as $key=>$val){
    $usersArr[$key] = $val ;
}
$isMobile = UtilService::isMobile() ;
$imgwidth = $isMobile==true?"225px":"400px" ;
?>
<style>
    table td{font-size: 17px;}
</style>

<div class="row">
    <div class="col-md-12">
        <div class="box box-solid">
            <div class="box-body   no-padding">
                <table class="table table-bordered table-striped table-condensed">
                    <tbody>
                        <tr>
                            <td width="30%">问题描述</td>
                            <td width="70%" style="word-break:break-all"><?= $feed['desc']; ?></td>
                        </tr>
                        <tr>
                            <td>名牌图片</td>
                            <?php if(!empty($feed['pic_url1'])):?>
                            <td><a href="<?= $feed['pic_url1']; ?>" target="_blank"><img src="<?= $feed['pic_url1']; ?>" style="width:<?=$imgwidth?>"></a></td>
                            <?php else :?>
                            <td></td>
                            <?php endif;?>
                        </tr>
                        <tr>
                            <td>问题图片1</td>
                            <?php if(!empty($feed['pic_url2'])):?>
                            <td><a href="<?= $feed['pic_url2']; ?>" target="_blank"><img src="<?= $feed['pic_url2']; ?>" style="width:<?=$imgwidth?>"></a></td>
                            <?php else :?>
                            <td></td>
                            <?php endif;?>
                        </tr>
                        <tr>
                            <td>问题图片2</td>
                            <?php if(!empty($feed['pic_url3'])):?>
                            <td><a href="<?= $feed['pic_url3']; ?>" target="_blank"><img src="<?= $feed['pic_url3']; ?>" style="width:<?=$imgwidth?>"></a></td>
                            <?php else :?>
                            <td></td>
                            <?php endif;?>
                        </tr>
                        <tr>
                            <td>视频</td>
                            <?php if(!empty($feed['video_url'])):?>
                                <td><video src="<?= $feed['video_url']; ?>" style="width:<?=$imgwidth?>" x-webkit-airplay="true" webkit-playsinline="" playsinline="true" preload="auto" controls="controls"></video></td>
                            <?php else :?>
                                <td></td>
                            <?php endif;?>
                        </tr>
                        <tr>
                            <td>公司名称</td>
                            <td><?= $feed['company_name']; ?></td>
                        </tr>
                        <tr>
                            <td>联系人</td>
                            <td><?= $feed['contact_name']; ?></td>
                        </tr>
                        <tr>
                            <td>联系方式</td>
                            <td><a href="tel:<?= $feed['contact']; ?>"><?= $feed['contact']; ?></a></td>
                        </tr>
                        <tr>
                            <td>地址</td>
                            <td><?= $feed['address']; ?></td>
                        </tr>
                        <tr>
                            <td>报修时间</td>
                            <td><?= $feed['add_time']; ?></td>
                        </tr>
                        <tr>
                            <td>当前处理人</td>
                            <td><?= $feed['deal_user_name']; ?></td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <!-- /.box-body -->
        </div>
    </div>

    <?php if($typeId==ConstatService::ADMIN_USER_TYPE_ID_MANAGER ||$typeId == ConstatService::ADMIN_USER_TYPE_ID_SUPER_ADMIN):?>

    <?php
    $form = ActiveForm::begin([
        'id' => 'input_form',
        'fieldConfig' => ['template' => "{input}{error}",'options'=>['class'=>'col-sm-3']],
        'options'=>[],
    ])
    ?>

    <div class="col-md-12">
        <div class="box box-solid">
            <div class="box-header with-border">
                <h3 class="box-title">修改处理人</h3>
            </div>
            <div class="box-body form-horizontal">
                <div class="form-group">
                    <label class="col-sm-1 control-label">处理人：</label>
                    <?= $form->field($model, 'deal_user_id')->dropDownList($usersArr); ?>
                </div>
            </div><!-- /.box-body -->
        </div>
    </div>

    <div class="col-md-12">
        <div class="box box-solid">
            <div class="box-body">
                <div class="col-sm-1">
                    <button type="button" class="btn btn-primary col-sm-12" id="form_submit">提交</button>
                </div>
            </div><!-- /.box-body -->
        </div>
    </div>
    <?php ActiveForm::end() ?>
    <?php endif;?>

</div>
<script>

    $("#form_submit").click(function(){
        var dealuserid = $('#changedealuserform-deal_user_id').val();
        if(dealuserid==0 ||dealuserid=="" || dealuserid==null){
            bootboxAlert("请选择处理人");
            return false ;
        }

        bootbox.confirm({
            buttons: {
                confirm: {
                    label: '确认',
                    className: 'btn-primary'
                },
                cancel: {
                    label: '取消',
                    className: 'btn-default'
                }
            },
            message: "确认修改吗？",
            callback: function(sure) {
                if(sure) {
                    var data = $('#input_form').serialize();
                    sendAjax('<?= Url::to(["/feed/change-deal-user","id"=>$feed["id"]]) ?>', data, $(this));
                }
            },
            title: "",
        });
    })
</script>